SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE Procedure [dbo].[TvShow_Insert_Seasons]
@SeriesName varchar(50), @SeasonNumber INT, @IsWatched BIT, @Image VARCHAR(MAX)
AS
Declare @TvId INT
SET @TvId = (Select Id from tv where title = @SeriesName)
IF NOT EXISTS(Select @Image From TvShow_Seasons WHERE TvId = @TvId AND Season = @SeasonNumber)
BEGIN
	Insert into TvShow_Seasons
		(TvId, Season, IsWatched, [Image], CreatedDate) 
	VALUES
		(@TvId, @SeasonNumber, @IsWatched, @Image, GetDate())
END
Select 'Inserted Successfully' as [message]
GO
